home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
38
/
sgn_bans.zip
/
PARSE2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-10-30
|
999b
|
44 lines
{ routine to parse a string into sub-strings }
Type
StrArray = array[1..10] of string[12] ;
CardImage = string[80] ;
Procedure Parse2(instring : CardImage ; var Answers : StrArray ;
var Entries, MaxEntries : integer) ;
{ MaxEntries sets max fields to parse. If 0 or -ve, all are parsed }
Var j, start : integer ;
Label 100, 200, 300, 400 ;
begin
Entries := 0 ;
j := 0 ;
100:
{ Start, or previous character was a space }
j := j + 1 ;
if j > length(instring) then goto 400 ;
if instring[j] <> ' '
then
begin
entries := entries + 1 ;
start := j ;
goto 200 ;
end
else goto 100 ;
200:
{ previous character was not a space }
j := j + 1 ;
if j > length(instring) then goto 300 ;
if instring[j] <> ' ' then goto 200 ;
300:
Answers[entries] := copy(instring,start,j-start) ;
if entries = MaxEntries then goto 400 ; { have parsed enough }
if j < length(instring) then goto 100 ;
400:
end ;